{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5. 数据结构\n",
    "本章深入讲解之前学过的一些内容，同时，还增加了新的知识点。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "arr:[1, 2, 3, 4, 5]\n"
     ]
    }
   ],
   "source": [
    "arr  = [1,2,3,4]\n",
    "\n",
    "arr.append(5)\n",
    "\n",
    "print(f\"arr:{arr}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 5, 5, 6]\n"
     ]
    }
   ],
   "source": [
    "arr2 = [5,6]\n",
    "arr.extend(arr2)\n",
    "print(arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "arr2:[5, 2, 6]\n"
     ]
    }
   ],
   "source": [
    "arr2.insert(1,2)\n",
    "print(f\"arr2:{arr2}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'list'>\n",
      "arr2 [5, 6]\n"
     ]
    }
   ],
   "source": [
    "print(type(arr2))\n",
    "arr2.remove(2)\n",
    "print(\"arr2\",arr2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "value 6\n",
      "arr2 [5]\n"
     ]
    }
   ],
   "source": [
    "value = arr2.pop()\n",
    "\n",
    "print(\"value\",value)\n",
    "\n",
    "print(\"arr2\",arr2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "arr4 [1, 2, 3, 4, 5]\n",
      "arr4_copy [5, 4, 3, 2, 1]\n"
     ]
    },
    {
     "ename": "",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31mThe Kernel crashed while executing code in the current cell or a previous cell. \n",
      "\u001b[1;31mPlease review the code in the cell(s) to identify a possible cause of the failure. \n",
      "\u001b[1;31mClick <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. \n",
      "\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
     ]
    }
   ],
   "source": [
    "arr4 = [1,2,3,4,5]\n",
    "arr4_copy = arr4.copy()\n",
    "\n",
    "arr4_copy.reverse()\n",
    "print(\"arr4\",arr4)\n",
    "print(\"arr4_copy\",arr4_copy)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
